--
-- public
--
--    Percentage: calculate percentage.
--
--       generic fixed point decimal for quantity arguments
--       generic fixed point decimal for results of calculation
--
--       Allows custom precision in percentage calculation.
--

generic

   -- precision for percentage results output

   type Percentage_Type is delta <> digits <>;

   -- precision for percentage quantity arguments

   type Qty_Type is delta <> digits <>;


package Percentages is

   Illegal_Quantity : exception;

   subtype Quantity_Precision_Type is Qty_Type;

--         with Dynamic_Predicate => Quantity_Precision_Type > -1.0;

   subtype Results_Precision_Type  is Percentage_Type;

--         with Dynamic_Predicate => Results_Precision_Type in 0.0..100.0;

   subtype Quantity_Type_Int is Integer

         with Dynamic_Predicate => Quantity_Type_Int > -1;

   subtype Percentage_Type_Int is Integer

         with Dynamic_Predicate => Percentage_Type_Int in 0..100;

   --
   -- Percentage
   --
   --    Calculation percentage.
   --

   function Percentage( Current_Qty  : in Quantity_Precision_Type;
                        Expected_Qty : in Quantity_Precision_Type )

         return Percentage_Type;


   function Percentage( Current_Qty  : in Quantity_Type_Int;
                        Expected_Qty : in Quantity_Type_Int )

                       return Percentage_Type_Int;


end Percentages;